package com.hngy.scala

import org.apache.spark.{SparkConf, SparkContext}

/**
  * 需求：RDD持久化
  */
object PersistRddScala {
  def main(args: Array[String]): Unit = {
    var conf = new SparkConf()
    conf.setAppName("PersistRddScala")
      .setMaster("local")
    val sc = new SparkContext(conf)

    val dataRDD = sc.textFile("D:\\b.txt").cache()

    var start_time = System.currentTimeMillis()
    var count = dataRDD.count()
    println(count)
    var end_time = System.currentTimeMillis()
    println("第一次耗时："+(end_time-start_time))

    start_time = System.currentTimeMillis()
    count = dataRDD.count()
    println(count)
    end_time = System.currentTimeMillis()
    println("第二次耗时："+(end_time-start_time))
    sc.stop()
  }
}
